<!--
 * @Description: examCourse -- 考试动态
 * @Author: your name
 * @Date: 2024-03-06
 * @LastEditTime: 2024-03-06
 * @LastEditors: Please set LastEditors
-->

<template>
  <div class="examCourse heart_w">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }"> 首页 </el-breadcrumb-item>
      <el-breadcrumb-item> 考试动态 </el-breadcrumb-item>
    </el-breadcrumb>

    <div class="row_con">
      <main class="col-md-8">
        <div class="panel panel-default">
          <div class="article_list">
            <article
              class="article_item"
              v-for="(item, index) in consultList"
              :key="index"
            >
              <div class="media">
                <div class="media-left">
                  <a href="javascript:void(0);">
                    <el-image :src="item.image"></el-image>
                  </a>
                </div>
                <div class="media-body">
                  <h3>
                    <a
                      :href="`#/articleDetails?id=${item.id}&type_id=${objId}`"
                      target="_blank"
                    >
                      {{ item.title }}
                    </a>
                  </h3>
                  <div class="article_tag">
                    <a href="javascript:void(0);">考试动态</a>
                    <span>{{ item.time }}</span>
                    <span title="浏览次数">
                      <i class="el-icon-view"></i>
                      {{ item.views }} 浏览
                    </span>
                  </div>
                </div>
              </div>
            </article>

            <div class="text-center">
              <!-- 分页 -->
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-size="pageSize"
                background
                layout="total, prev, pager, next, jumper"
                :total="total"
              >
              </el-pagination>
            </div>
          </div>
        </div>
      </main>

      <aside class="col-md-8 right-nav">
        <!-- 报考指南 -->
        <div class="text_guide">
          <h3>报考指南</h3>
          <ul class="nine_ul">
            <li v-for="item_li in menuList" :key="item_li.id">
              <a href="#">
                <img :src="item_li.image" alt="" style="width: 100%" />
                <p>{{ item_li.name }}</p>
              </a>
            </li>
          </ul>
        </div>

        <!-- 免费资料下载 -->
        <div class="download_rank" v-if="false">
          <h3>免费资料下载</h3>
          <ul>
            <li v-for="down_item in 3" :key="down_item">
              <a href="#">
                <img
                  src="https://www.rongyuejiaoyu.com/static/material/assets/images/tubiao.png"
                  alt=""
                />
                <span>2024年CFA考试三级考纲变化解读</span>
                <button>下载</button>
              </a>
            </li>
          </ul>
        </div>

        <!-- 阅读排行 -->
        <div class="read_rank">
          <h3>阅读排行</h3>
          <ul>
            <li v-for="(item, i) in readingRanking" :key="i">
              <i>{{ i + 1 }}</i>
              <a href="#" :title="item.title" target="_blank">
                {{ item.title }}
              </a>
            </li>
          </ul>
        </div>

        <!-- 课程推荐 -->
        <div class="remen_live" v-if="false">
          <h3>课程推荐</h3>
          <div class="flashSale_wrap">
            <el-carousel
              trigger="click"
              height="140px"
              :autoplay="false"
              indicator-position="none"
            >
              <el-carousel-item v-for="item in 3" :key="item">
                <a href="#" rel="nofollow" target="_blank">
                  <img
                    src="https://video.rycfa.com/image/default/34CCE1ACBFF3442DBBC3A34E94D2565A-6-2.jpg"
                    alt=""
                  />
                </a>
              </el-carousel-item>
            </el-carousel>
          </div>
        </div>

        <!-- 热门推荐 -->
        <div class="finance_interview">
          <h3>热门推荐</h3>
          <div class="interview_news">
            <a
              href="#"
              title="2024年5月CFA考试地点能改吗?"
              target="_blank"
              v-for="item_a in ArticleList"
              :key="item_a.id"
            >
              {{ item_a.title }}
            </a>
          </div>
        </div>
      </aside>
    </div>
  </div>
</template>

<script>
import {
  getArticleListForTui,
  getSearchLog,
  getMenu,
  getArticleList
} from '@/api/consult/zixun.js'
export default {
  name: 'examCourse',
  data() {
    return {
      total: 1,
      currentPage: 1, // 当前页码默认值为1
      pageSize: 10, // 每页显示条数默认值为10
      consultList: [],
      ArticleList: [], // 热门推荐
      readingRanking: [],
      menuList: [],
      objId: 1
    }
  },
  created() {
    this.objId = this.$route.query.tabIds
    console.log(this.$route.query.tabIds)
    this.getConsultingService()
  },
  methods: {
    getConsultingService() {
      let _that = this

      // 获取热门推荐
      let params_t = {
        cate_id: 1,
        type_id: 1
      }
      getArticleListForTui(params_t).then(({ data: data_t }) => {
        _that.ArticleList = data_t.data
      })

      // 阅读排行
      let params_paih = {
        cate_id: 1,
        type_id: 1
      }
      getSearchLog(params_paih).then(({ data: data_p }) => {
        _that.readingRanking = data_p.data
      })

      getMenu({ cate_id: this.objId, type_id: 1 }).then(({ data: data }) => {
        this.menuList = data.data
      })

      getArticleList({
        cate_id: this.objId,
        type_id: 1,
        page: this.currentPage
      }).then(({ data: data_list }) => {
        this.consultList = data_list.data.list
        this.total = data_list.data.total
      })
    },
    //切换分页大小
    handleSizeChange(size) {
      this.pageSize = size
      // 调用函数
      this.pdfData(this.phaseId, this.rankId)
    },

    //切换分页
    handleCurrentChange(current) {
      this.currentPage = current
      console.log('当前页', current)
      this.pdfData(this.phaseId, this.rankId)
    }
  }
}
</script>

<style scoped lang="scss">
@import '@/assets/styles/hotspot_details.scss';

// @media (max-width: 920px) {
//   .col-md-8 {
//     width: 66.66666667%;
//   }
// }

::v-deep {
  .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #2c3e50;
    color: #fff;

    &.active:hover {
      color: #fff;
    }
  }

  .el-pagination.is-background .el-pager li:not(.disabled):hover {
    color: #606266;
  }
}

.examCourse {
  margin-bottom: 90px;
  .el-breadcrumb {
    height: 40px;
    line-height: 40px;
    font-size: 15px;
    color: #444;
    background-color: #fff;
    padding: 12px 8px;
    margin: 14px 0;
    border-radius: 3px;
  }
}

.panel {
  padding: 0 15px;
  background-color: #fff;
  .article_list {
    padding: 0;
    background-color: #fff;

    .text-center {
      padding: 40px 0 20px 0;
      text-align: center;
    }
  }
}
.article_item {
  padding: 20px 0;
  border-bottom: 1px solid #efefef;

  .media {
    display: flex;
    // align-items: center;
    .media-left {
      a {
        display: block;
        width: 160px;
        // height: 120px;
        ::v-deep .el-image__inner {
          transition: all 0.3s;
        }
      }
      a:hover {
        ::v-deep .el-image__inner {
          transition: all 0.3s;
          transform: scale(1.1);
        }
      }
      .el-image {
        height: 120px;
        width: 160px;
      }
    }
    .media-body {
      padding-left: 20px;
      line-height: 25px;
      flex: 2;
      height: 120px;
      font-size: 1em;
      position: relative;
      .article_tag {
        display: block;
        clear: both;
        color: #aaa;
        font-size: 14px;
        position: absolute;
        bottom: 0;
        a {
          display: inline-block;
          padding: 0 8px;
          height: 24px;
          line-height: 24px;
          font-weight: 400;
          font-size: 13px;
          text-align: center;
          color: #0084ff;
          background: rgba(0, 132, 255, 0.1);
          margin-right: 3px;
          border-radius: 2px;
        }

        span {
          margin: 0 8px;
          color: #aaa;
          font-size: 14px;
        }
      }

      h3 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 590px;
        margin: 0;
        font-size: 1em;
        line-height: 1.45;
        margin-bottom: 5px;
        color: #444;

        a {
          font-size: 1.25em;
        }

        a:hover {
          text-decoration: underline;
          color: #007bff;
          transition: all 0.3s ease;
        }
      }
    }
  }
}

/* 右侧 */

ul {
  list-style: none;
}

/* 课程推荐 */
.remen_live {
  @include text_tit();
  height: 252px;
  box-sizing: border-box;

  h3 {
    @include h3_cont();
  }
  .flashSale_wrap {
    ::v-deep {
      .el-carousel__item {
        text-align: center;
      }

      .el-carousel__arrow {
        display: block !important;
        width: 26px;
        height: 50px;
        background: #2a4c7e;
        border-radius: 3px;

        i {
          font-size: 18px;
          font-weight: bold;
        }
      }

      .carousel-arrow-left-enter:hover {
        transform: none !important;
        opacity: 0;
      }
    }

    a {
      height: 140px;
      width: 210px;
      display: inline-block;
      padding: 0 15px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
